from flask_restful import fields

SwiperFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'img': fields.String,
        'link': fields.String,
        'desc': fields.String
    }, allow_null=True, default={}))
}


OneSwiperFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'img': fields.String,
        'link': fields.String,
        'desc': fields.String
    })
}


DescFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'title': fields.String,
        'desc': fields.String
    }, allow_null=True, default={}))
}
DescOneFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'title': fields.String,
        'desc': fields.String
    }, allow_null=True, default={})
}


GoodnessFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'content': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True)
}

ProductExamplesFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'img': fields.String,
        'desc': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={}))
}
ProductOneExamplesFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'img': fields.String,
        'desc': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={})
}

ArticleFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'title': fields.String,
        'content': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={}))
}

ProductListFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'name': fields.String,
        'img': fields.String,
        'desc': fields.String,
        'types': fields.List(fields.Nested({
            'price': fields.String
        })),
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={}))
}

ProductOneFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'name': fields.String,
        'img': fields.String,
        'desc': fields.String,
        'types': fields.List(fields.Nested({
            'price': fields.String
        })),
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={})
}

ProductALLFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'name': fields.String,
        'img': fields.String,
        'desc': fields.String,
        'types': fields.List(fields.Nested({
            'id': fields.Integer,
            'price': fields.String,
            'name': fields.String,
            'desc': fields.String,
            'price': fields.String,
            'f_limit':fields.Integer,
            'type':fields.Integer
        })),
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={})
}

OrderOneFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
        'pay_number': fields.String,
        'pay_channels': fields.String(attribute=lambda x: '微信' if x.pay_channels == 1 else '支付宝'),
        'order_number': fields.String,
        'trade_no': fields.String,
        'products': fields.List(fields.Nested({
            'product': fields.String(attribute='product.name'),
            'number': fields.Integer,
            'usenumber': fields.List(fields.Nested({
                'card_number': fields.String,
                'is_use': fields.Boolean
            }))
        }))
    }, allow_null=True)
}

OrderListFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
        'pay_number': fields.String,
        'pay_channels': fields.String(attribute=lambda x: '微信' if x.pay_channels == 1 else '支付宝'),
        'order_number': fields.String,
        'trade_no': fields.String,
        'is_pay':fields.Boolean,
        'products': fields.List(fields.Nested({
            'product': fields.String(attribute='product.name'),
            'number': fields.Integer,
            'usenumber': fields.List(fields.Nested({
                'card_number': fields.String,
                'is_use': fields.Boolean
            }))
        }))
    }, allow_null=True))
}



TutorialsFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data': fields.List(fields.Nested({
        'id': fields.Integer,
        'video': fields.String,
        'desc': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={}))
}
TutorialsOneFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'video': fields.String,
        'desc': fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    }, allow_null=True, default={})
}

FrontUseOnerFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'login_name': fields.String,
        'nick_name': fields.String,
        'avatar': fields.String,
        'is_distribution': fields.Boolean,
        'qrcode':fields.String,
        'commission':fields.String,
        'level':fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    },  default={})
}